﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ServBus.ListForm2013.Setup.Commands;
using ServBus.ListForm2013.Setup.Validators;

namespace ServBus.ListForm2013.Setup.SubForms
{
    public partial class ChooseBatchForm : BaseStepForm
    {
        private SolutionStatus status;

        public ChooseBatchForm()
        {
            InitializeComponent();
        }

        public ChooseBatchForm(BaseStepForm previous, SetupForm setupForm, SolutionStatus status)
            : base(previous, setupForm)
        {
            InitializeComponent();
            this.status = status;
        }

        public override string Title
        {
            get
            {
                return Properties.Resources.BatchTitle;
            }
        }

        public override string SubTitle
        {
            get
            {
                return Properties.Resources.BatchSubTitle;
            }
        }

        public override void Init()
        {
            this.labelBatch.Text = Properties.Resources.BatchText;
            this.radioRemove.Text = Properties.Resources.BatchRemove;
            this.labelRemove.Text = Properties.Resources.BatchRemoveDesc;
            if (this.status == SolutionStatus.Older)
            {
                this.radioRepairUpgrade.Text = Properties.Resources.BatchUpgrade;
                this.labelRepairUpgrade.Text = Properties.Resources.BatchUpgradeDesc;
            }
            else
            {
                this.radioRepairUpgrade.Text = Properties.Resources.BatchRepair;
                this.labelRepairUpgrade.Text = Properties.Resources.BatchRepairDesc;
            }
            this.ParentSetupForm.PrevButton.Enabled = true;
            this.ParentSetupForm.NextButton.Enabled = true;
        }

        public override BaseStepForm CreateNextStep()
        {
            InstallBatch batchType;
            if (radioRepairUpgrade.Checked)
            {
                if (status == SolutionStatus.Older)
                    batchType = InstallBatch.Upgrade;
                else
                    batchType = InstallBatch.Repair;
            }
            else
            {
                batchType = InstallBatch.Remove;
            }
            return new OperationForm(this, this.ParentSetupForm, batchType);
        }
    }
}
